package com.xjscrm.console.mapper;

import com.xjscrm.common.entity.WwTags;
import com.xjscrm.console.param.wwCustomer.CustomerTagQuery;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface WwTagsMapper {

    List<WwTags> getCustomerTag(CustomerTagQuery customerTagQuery);

    int addWwTags(WwTags wwTags);

    WwTags getById(@Param("id") Long id, @Param("merId") Long merId);

    List<WwTags> getByIds(@Param("ids") List<Long> ids, @Param("merId") Long merId);

    void insertWwTags(WwTags wwTags);

    List<WwTags> getCustomerTagTree(CustomerTagQuery customerTagQuery);


    int deleWwTagsById(@Param("id") Long id, @Param("merId") Long merId);

    void updateWwTags(WwTags wwTags);

    List<WwTags> selectListByIds(@Param("merId") Long merId, @Param("ids") List<Long> ids);

    WwTags getdefultParentTag(@Param("merId") Long merId, @Param("deviceUniqueId") Long deviceUniqueId);

    // 根据标签名和企业corpId查询企业标签
    List<WwTags> selectByType1AndPid0TagNameAndCorpId(@Param("merId") Long merId, @Param("groupName") String groupName, @Param("corpId") String corpId);

    // 根据externalId查询企业标签
    WwTags selectByType1ExternalId(@Param("merId") Long merId, @Param("externalId") String externalId);

    // 根据corpId和标签名查询企业标签
    WwTags selectByType1AndPidCorpIdAndTagName(@Param("merId") Long merId, @Param("corpId") String corpId, @Param("tagName") String tagName, @Param("pid") Long pid);

    // 根据pid删除子企业标签
    int deleteByParentId(@Param("merId") Long merId, @Param("pid") Long pid);

    List<WwTags> selectByType1Pid(@Param("merId") Long merId, @Param("pid") Long pid);

    List<WwTags> selectByType1AndPid0CorpId(@Param("merId") Long merId, @Param("corpId") String corpId);

    WwTags selectByType1AndPid0TagIdAndCorpId(@Param("merId") Long merId, @Param("groupId") String groupId, @Param("corpId") String corpId);

    List<WwTags> selectByType1PidCorpId(@Param("merId") Long merId, @Param("pid") Long pid, @Param("corpId") Long corpId);
}
